﻿using PoemGame.ComputerAnswer.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PoemGame.ComputerAnswer.Xml
{
    public class ComputerAnswerDuishi : ComputerAnswerBase, IComputerAnswer
    {
        public ComputerAnswerDuishi() : base()
        {

        }
        public string Answer(string gamecontext,string lastanswer)
        {
            var rows = poemlinedt.Select("LineContent='" + lastanswer + "'");
            if (rows.Count() > 0)
            {
                              
                var poemId = rows[0]["PoemId"].ToString();
                var order= int.Parse(rows[0]["Order"].ToString()); 
                var lines= poemlinedt.Select("PoemId='" + poemId + "'");
                foreach(var line in lines)
                {
                    var order1 = int.Parse(line["Order"].ToString());
                    if(order1==order+1) return line["LineContent"].ToString();
                }
            }
            return "";
        }
    }
}
